/**
 *
 * \file DirParser.h
 * \brief DirParser definition class for Linux platforms
 * \author Edouard ROGE
 * \date 27 february 2011
 *
 */

#ifndef _DIRPARSER_LINUX_
#define _DIRPARSER_LINUX_

#include <dirent.h>
#include "URI.h"
#include "Core/Memory/HeapObject.h"

/**
 * \class DirParser
 * \brief Object which parse all file in a given directory
 */
class DirParser : public HeapObject
{
public:
	/**
	 * \fn DirParser();
	 * Default constructor
	 */
	DirParser();

	/**
	 * \fn ~DirParser();
	 * Destructor
	 */
	~DirParser();

	/**
	 * \fn const URI & GetURI() const;
	 * \return the URI of the parsed directory
	 */
	const URI & GetURI() const { return m_URI; }

	/**
	 * \fn bool Open( const std::string & _strURI, const std::string & _strExt );
	 * \param _strURI URI of the directory
	 * \param _strExt filter : keep only files with the extenstion _strExt
	 * \return true if the directory is found
	 */
	bool Open( const std::string & _strURI, const std::string & _strExt );

	/**
	 * \fn bool Close();
	 * \return true if the directory is correctly closed
	 */
	bool Close();

	/**
	 * \fn bool Iterate( std::string & _strFileName );
	 * \param _strFileName if found, returns the name of the next file found
	 * \return true if a file is found
	 */
	bool Iterate( std::string & _strFileName );

private:
	/** URI of the directory */
	URI m_URI;

	/** directory */
	struct dirent * m_Ent;

	/** directory */
	DIR			  * m_Dir;
};


#endif //_DIRPARSER_LINUX_
